module MicropostsHelper
	#include ActionView::Helpers::SanitizeHelper
	#include ActionView::Helpers::SanitizeHelper::ClassMethods
	#include Rails::Html::Sanitizer

	def wrap(content)
		#ser = Rails::Html::Sanitizer.new
  		#ActionController::Base.helpers.sanitize(content.split.map{ |s| wrap_long_string(s) }.join(' ').html_safe)
  		ActionController::Base.helpers.sanitize content.split.map{ |s| wrap_long_string(s) }.join
  		#content.split.map{ |s| wrap_long_string(s) }.join.html_safe
	end 

	private
    	def wrap_long_string(text, max_width = 30)
      		#zero_width_space = "&#8203;"
      		zero_width_space = "<br />"
      		regex = /.{1,#{max_width}}/
      		(text.length < max_width) ? text :text.scan(regex).join(zero_width_space)
		end
end